<?php

if (!function_exists('get_tree')) {
    function get_tree(array $list, int $increment = 0): array
    {
        $data = [];
        foreach ($list as $item) {
            if ($item['pid'] == $increment) {
                $item['children'] = get_tree($list, $item['id']);
                $data[] = $item;
            }
        }
        return $data;
    }
}
